home *** CD-ROM | disk | FTP | other *** search
/ Computer Inter@ctive 17 / Computer Interactive cdrom 17 - gen 99.iso / ZDNETIT / CONTENT / SMTPCEMS.ZIP / DELETE.C < prev    next >
Encoding:
C/C++ Source or Header  |  1998-11-15  |  1.4 KB  |  63 lines

  1. /*
  2. **  DELETE.C [edit EMAIL.H before compiling]
  3. **
  4. **  This program deletes the specified email 
  5. **  message on the SMTP server.
  6. */
  7.  
  8. #include <windows.h>
  9. #include <stdio.h>
  10. #include <stdlib.h>
  11. #include "see.h"
  12. #include "email.h"
  13.  
  14. static char Buffer[512];
  15.  
  16. void ErrorExit(int Code)
  17. {seeErrorText(Code,(LPSTR)Buffer,512);
  18.  printf("SEE Error %d: %s\n", Code, Buffer);
  19.  seeClose();
  20.  exit(1);
  21. }
  22.  
  23. void main(int argc, char *argv[])
  24. {int i;
  25.  int Code; 
  26.  int MsgNbr1;
  27.  int MsgNbr2;
  28.  if(argc!=3)
  29.    {printf("Usage: DELETE <MsgNbr1> <MsgNbr2>\n");
  30.     exit(1);
  31.    }
  32.  MsgNbr1 = atoi(argv[1]); 
  33.  MsgNbr2 = atoi(argv[2]);
  34.  if(MsgNbr1>MsgNbr2)
  35.    {printf("Msg %d must be less than Msg %d\n",MsgNbr1,MsgNbr2);
  36.     exit(1);
  37.    }
  38.  if(MsgNbr1<1)
  39.     {printf("MsgNbr1 = %d too small\n", MsgNbr1);
  40.      exit(1);
  41.    }
  42.  
  43.  /* define diagnostics log file */
  44.  ///seeStringParam(SEE_LOG_FILE, (LPSTR)"delete.log"); 
  45.  /* connect to POP3 server */
  46.  printf("Connecting to %s ...",(LPSTR)POP3_HOST_NAME);
  47.  Code = seePop3Connect(
  48.     (LPSTR)POP3_HOST_NAME,              
  49.     (LPSTR)POP3_USER_NAME,               
  50.     (LPSTR)POP3_PASSWORD);
  51.  if(Code>=0) printf("OK\n");
  52.  else ErrorExit(Code); 
  53.  /* delete message(s) */
  54.  for(i=MsgNbr2;i>=MsgNbr1;i--)
  55.    {printf("Deleting message %d...\n",i);
  56.     Code = seeDeleteEmail(i);                   
  57.     if(Code<0) ErrorExit(Code);
  58.    } 
  59.  seeClose();
  60. } /* end main */
  61.  
  62.  
  63.